package com.cms.biz.rsf;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.cms.bean.AttachmentBean;

public class AttachmentHelper {
	
	public static void addAttachment(Connection conn,AttachmentBean attachBean){
		PreparedStatement pst=null;
		try {
			pst = conn.prepareStatement(SQLString.ADD_RSF_ATTACHMENT);
			pst.setInt(1, attachBean.getId());
			pst.setInt(2, attachBean.getParentId());
			pst.setString(3, attachBean.getSuffix());
			pst.setString(4, attachBean.getFileName());
			pst.setString(5, attachBean.getCreateUser());
			pst.execute();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally{
			if (pst != null) {
				try {
					pst.close();
					pst = null;
				} catch (final SQLException e) {
				}
			}
		}
	}
	
	public static void delAttachment(Connection conn,int id){
		PreparedStatement pst=null;
		try {
			pst = conn.prepareStatement(SQLString.DELETE_RSF_ATTACHMENT);
			pst.setInt(1, id);
			pst.execute();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally{
			if (pst != null) {
				try {
					pst.close();
					pst = null;
				} catch (final SQLException e) {
				}
			}
		}
	}

}
